package net.ix.opal;

import net.ix.opal.service.IFileListService;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

public class ServiceTest extends Activity {
	private IFileListService fileListService;
	private ServiceConnection serviceConn = new ServiceConnection(){
		public void onServiceConnected(ComponentName name, IBinder service) {
			fileListService = (IFileListService)service;
			Log.v("ServiceTest", "on service connected, count is " + fileListService.getCount());
		}
		public void onServiceDisconnected(ComponentName name) {
			fileListService = null;
		}
	};
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.bindService(new Intent("net.ix.FileListService"), this.serviceConn, BIND_AUTO_CREATE);
	}
	
	@Override
	protected void onDestroy() {
		this.unbindService(serviceConn);
		super.onDestroy();
	}
}